package com.ctech.wsgen.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

import com.ctech.wsgen.model.ItemCategory;

public class ItemCategoryRowMapper implements RowMapper {

	public Object mapRow(ResultSet rs, int line) throws SQLException {
		ItemCategoryResultSetExtractor extractor = new ItemCategoryResultSetExtractor();
		return extractor.extractData(rs);
	}

	private class ItemCategoryResultSetExtractor implements ResultSetExtractor {

		public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
			ItemCategory item = new ItemCategory(
					rs.getInt("ID"), 
					rs.getString("VENDOR_TITLE_NAME"), 
					rs.getString("Trimmed_Part#"), 
					rs.getString("W_DESCRIPTION"), 
					rs.getBigDecimal("Price"),
					rs.getString("CAT_FILENAME"),
					rs.getString("CAT_TITLE_NAME"),
					rs.getString("GROUP_NAME")
			);
			return item;
		}

	}

}
